package com.xxjh.brs.map.enums;

/**
 * @author CHENCHEN
 * @title a
 * @company 新兴际华科技（天津）有限公司
 * @create 2024-06-27 18:40
 */
public enum MapServiceType {
    // 3D影像地图服务
    THREE_T("3D影像地图", "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/%d/%d/%d"),
    // 2D高德矢量地图服务
    TWO_D("2D高德矢量图", "http://wprd04.is.autonavi.com/appmaptile?x=%d&y=%d&z=%d&lang=zh_cn&size=1&scl=1&style=7");

    public static final String MAP_3T = "ttt";
    public static final String MAP_2D = "2d";
    private static final String RESOURCES_PATH = "D:/map/%s/%d/%d/%d.png";
    private final String alias;
    private final String urlFormat;
    public static final int MAXHEIGHT = 20;

    MapServiceType(String alias, String urlFormat) {
        this.alias = alias;
        this.urlFormat = urlFormat;
    }

    // 格式化并返回URL
    public String getUrl(int x, int y, int z) {
        if (this == THREE_T) {
            // 注意：对于3D影像地图，通常z是层级，y是列(x坐标)，x是行(y坐标)，与您的原始描述相符。
            return String.format(urlFormat, z, y, x);
        } else if (this == TWO_D) {
            // 对于2D高德地图，x、y、z的顺序与您的描述一致。
            return String.format(urlFormat, x, y, z);
        }
        throw new IllegalStateException("Unsupported map adapter type.");
    }



    // 获取别名
    public String getAlias() {
        return alias;
    }

    public static void main(String[] args) {
        // 生成3D地图服务的URL
        String threeDUrl = MapServiceType.THREE_T.getUrl(1, 2, 3);
        System.out.println("3D Map URL: " + threeDUrl);

        // 生成2D地图服务的URL
        String twoDUrl = MapServiceType.TWO_D.getUrl(1, 2, 3);
        System.out.println("2D Map URL: " + twoDUrl);
    }
}
